import { request } from '../utils/request'
const getArticleDetailAPI = ({ Id }) => {
  return request({
    url: '/v1_0/articles/' + Id
  })
}
// 文章页-关注作者
const followAutAPI = (target) => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target
    }
  })
}
// 文章页-取注作者
const unfollowAutAPI = (Id) => {
  return request({
    method: 'DELETE',
    url: '/v1_0/user/followings/' + Id
  })
}
// 喜欢
const articleLikeAPI = (target) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target
    }
  })
}
// 不喜欢
const articleDisLikeAPI = (id) => {
  return request({
    method: 'DELETE',
    url: '/v1_0/article/likings/' + id
  })
}
// 评论
const commentListAPI = ({ artId, offset, limit = 10 }) => {
  return request({
    url: '/v1_0/comments',
    params: {
      type: 'a',
      source: artId,
      offset,
      limit
    }
  })
}
// 点赞
const commentLikingAPI = (target) => {
  return request({
    url: '/v1_0/comment/likings',
    method: 'POST',
    data: {
      target
    }
  })
}
// 取消点赞
const commentDisLikingAPI = (id) => {
  return request({
    url: '/v1_0/comment/likings/' + id,
    method: 'DELETE'
  })
}
// 获取内容
const sendCommentAPI = ({ target, content }) => {
  return request({
    method: 'POST',
    url: '/v1_0/comments',
    data: {
      target,
      content
    }
  })
}
export {
  getArticleDetailAPI,
  followAutAPI,
  unfollowAutAPI,
  articleLikeAPI,
  articleDisLikeAPI,
  commentListAPI,
  commentLikingAPI,
  commentDisLikingAPI,
  sendCommentAPI
}
